package com.sanyang.logistics.zhd.handler;


import java.util.List;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sanyang.logistics.pojo.DriverDim;
import com.sanyang.logistics.zhd.service.DriverService;

@RequestMapping("/driver")
@Controller
public class DriverHandler {
	
	
	@Autowired
	private DriverService drservice;
	
	@RequestMapping("/selectDriver")
	@ResponseBody
	public Object selectDriver(DriverDim driverDim){

		List<DriverDim> driver = drservice.selectDriver(driverDim);
		return driver;
	}
	
	@RequestMapping("/delDriver")
	@ResponseBody
	public Object delDriver(Integer driver_id) {
		return "del";
	}
	
	@RequestMapping("/addOne")
	@ResponseBody
	public Object addOne(DriverDim driverDim) {
		
		drservice.addOne(driverDim);
		return "add";
	}
	
	@RequestMapping("/selectOne")
	@ResponseBody
	public Object selectOne(Integer driver_id) {
		DriverDim selectOne = drservice.selectOne(driver_id);

		return selectOne;
	}
	
	@RequestMapping("/upDriver")
	@ResponseBody
	public Object upDriver(DriverDim driverDim) {
		System.out.println("修改");
		drservice.upDriver(driverDim);
		return "up";
	}
	
	
	@RequestMapping("/selectByLicense")
	@ResponseBody
	public Object selectByLicense(DriverDim driverDim) {
		System.out.println(driverDim.getContact());
		System.out.println(driverDim.getLicense());
		DriverDim selectByLicense = drservice.selectByLicense(driverDim);
		
		if (selectByLicense!=null) {
			return 1;
		}
		return 0;
	}

}
